<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width = device-width, initial-scale = 1.0, maximum-scale = 1.0, user-scalable = 0">
	
<title>修改昵称</title>

<link href="static/Theme/css/base.css" rel="stylesheet">
<link href="static/Theme/css/user.css" rel="stylesheet">
</head>

<body>
<header class="header">
	<div class="header-return">
	    <a href="javascript:history.go(-1);"></a>
	</div>
	
	<div class="logo">修改昵称</div>
</header>

<section class="container">
	<div class="setting-form">
		<div class="form-widget">
			<form>
				<div class="form-box">
					<div class="form-group">
						<label class="form-label">昵称</label>

						<div class="form-control">
							<input placeholder="请输入昵称" name="nick" value={$user['name']}>
						</div>
					</div>
				</div>

				<div class="form-submit">
					<button type="button" id="save" class="form-submit-btn">确定</button>
				</div>
			</form>
		</div>
	</div>
</section>
<script src="static/Theme/js/jquery-1.11.2.min.js"></script>
<script src="static/Theme/js/main.js"></script>
<script>
	$("#save").click(function () {
		let nick = $("input[name='nick']").val();
		if(!nick){
			alert("请设置昵称");
			return false;
		}else{
			checkNick();
		}
	})
	function checkNick(){
		let nick = $("input[name='nick']").val();
		$.ajax({
			type: "POST",
			url: "editNick",
			data: {nick:nick},
			dataType: "json",
			success: function (res) {
				if (res.code == 500) {
					alert(res.msg);
					return false;
				}else{
					alert(res.msg);
					setTimeout("top.location.href = '" + res.data + "'",500);
				}
			}
		});
	}
</script>
</body>
</html>
